//
//  GYAddressCell.m
//  GoodLuck
//
//  Created by 郭为勇 on 2018/3/4.
//  Copyright © 2018年 yunjiazhineng. All rights reserved.
//

static NSString *addressCellIdentifier = @"addressCellIdentifier";

#import "GYAddressCell.h"

@interface GYAddressCell ()

@property (weak, nonatomic) IBOutlet UILabel *nameLable;
@property (weak, nonatomic) IBOutlet UILabel *phoneLable;
@property (weak, nonatomic) IBOutlet UILabel *addressLable;
@property (weak, nonatomic) IBOutlet UILabel *defaultLable;

@end
@implementation GYAddressCell

+(instancetype)cellWithTableView:(UITableView *)tableView {
    GYAddressCell *cell = [tableView dequeueReusableCellWithIdentifier:addressCellIdentifier];
    if (cell == nil) {
        cell = [[[NSBundle mainBundle] loadNibNamed:@"GYAddressCell" owner:nil options:nil] firstObject];
    }
    return cell;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
}

- (void)setAddress:(GYRecriveAddress *)address {
    _address = address;
    
    self.nameLable.text = address.true_name;
    self.phoneLable.text = address.mob_phone;
    self.addressLable.text = [NSString stringWithFormat:@"%@  %@",address.area_info,address.address];
    
    self.defaultLable.hidden = address.is_default == 0 ? YES : NO;
}

- (CGFloat)cellHeight:(GYRecriveAddress *)model {
    
    self.address = model;
    
    [self layoutIfNeeded];
    
    return CGRectGetMaxY(self.defaultLable.frame) +15;
}

- (IBAction)onClick:(UIButton *)sender {
    self.btuClickBlock(sender.tag,self.currentRow);
}

@end
